package com.itheima.service.Impl;


import com.itheima.mapper.DeptMapper;
import com.itheima.pojo.Dept;
import com.itheima.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {         //请求处理

    @Autowired
    private DeptMapper deptMapper;
    @Override
    public List<Dept> getDeptList() {
        return deptMapper.getDeptList();
    }

    @Override
    public void delDept(Integer id) {
        deptMapper.delDept(id);
    }

    @Override
    public void addDept(Dept dept) {

        dept.setUpdateTime(LocalDateTime.now());
        dept.setCreateTime(LocalDateTime.now());
        deptMapper.addDept(dept);
    }


    /**
     * 修改部门接口前的回显功能实现的逻辑实现。
     * @param id
     * @return
     */
    @Override
    public Dept getDeptById(Integer id) {
        Dept dept = deptMapper.getDeptById(id);
        return dept;
    }

    @Override
    public void modifyDept(Dept dept) {

        deptMapper.updateDept(dept);
    }


}
